package bookManager.operation;

import bookManager.Book;
import bookManager.BookDao;

import java.util.Scanner;

public class AddOperation implements IOperation{
    @Override
    public void work() {

        // 先让用户输入书的信息. 构造 Book 对象, 插入到数据库中.
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入图书的名字: ");
        String name = scanner.next();
        System.out.println("请输入图书的作者: ");
        String author = scanner.next();
        System.out.println("请输入图书的价格: ");
        int price = scanner.nextInt();
        System.out.println("请输入图书的类型: ");
        String type = scanner.next();

        Book book=new Book();
        book.setName(name);
        book.setAuthor(author);
        book.setPrice(price);
        book.setType(type);
        // 由于新书应该是处于 "未借出" 的状态, 这个状态已经在 BookDao 的 add 方法中写死了.

        BookDao bookDao=new BookDao();
        bookDao.add(book);
    }
}
